import * as Cesium from "cesium/Cesium";

// import VerticalOrigin from "cesium/Source/Scene/VerticalOrigin"

const geojson = () => {
    console.log('1111');
    let geojsonOptions = {
        clampToGround: true
    }
    let neighborhoodsPromise = Cesium.GeoJsonDataSource.load('http://202.115.139.135:2000/geoserver/huangong/wms?service=WMS&version=1.1.0&request=GetMap&layers=huangong:png-qingping&styles=&bbox=104.069,31.489,104.163,31.607&width=611&height=768&srs=EPSG:4326&format=application/openlayers#toggle', geojsonOptions)
    // let neighborhoods
    neighborhoodsPromise.then(function (dataSource) {
        // viewer.dataSource.add(dataSource)
        // neighborhoods = dataSource.entities

        let neighborhoodsEntities = dataSource.entities.value
        for (let i = 0; i < neighborhoodsEntities.length; i++) {
            let entity = neighborhoodsEntities[i]
            if (Cesium.defined(entity.polygon)) {
                entity.name = entity.properties.neighborhood
                entity.polygon.material = Cesium.Color.fromRandom({
                    red: 0.1,
                    maximumGreen: 0.5,
                    minimumBlue: 0.5,
                    alpha: 0.6
                })
                // entity.polygon.classificationType = Cesium.classificationType.TERRAIN
                // let polyPositions = entity.polygon.hoerarchy.getValue(cesium.JulianDate.now()).polyPositions
                // let polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center

                // polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter)
                // entity.position = polyCenter
                entity.label = {
                    text: entity.name,
                    showBackground: true,
                    scale: 0.6,
                    horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                    VerticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                    distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10.0, 8000.0),
                    disableDepthTestDistance: 100.0
                }
            }
        }
    })
}
export default geojson